﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace S4Store.Domain
{
    public class Employee
    {
        public int Id { get; set; }
        public int StoreId { get; set; }
        public String Name { get; set; }
        public String Tel { get; set; }
        public int SexType { get; set; }
        public DateTime WorkStartDate { get; set; }
        public DateTime Birthday { get; set; }
        public DateTime EmployedDate { get; set; }
        public bool IsClose { get; set; }
        public int GradeValue { get; set; }
        public int StatusValue { get; set; }
        public int TypeValue { get; set; }
        public EmployeeType Type
        {
            get { return TypeValue.ToEnum<EmployeeType>(); }
            set { TypeValue = value.ToInt(); }
        }

        public Sex Sex
        {
            get { return SexType.ToEnum<Sex>(); }
            set { SexType = value.ToInt(); }
        }

        public SellerGrade SellerGrade
        {
            get { return GradeValue.ToEnum<SellerGrade>(); }
            set { GradeValue = value.ToInt(); }
        }
        public Status Status
        {
            get { return StatusValue.ToEnum<Status>(); }
            set { StatusValue = value.ToInt(); }
        }

        public virtual Store Store { get; set; }

        public int WorkYear
        {
            get
            {
                TimeSpan span = DateTime.Now - this.WorkStartDate;
                return (int) span.TotalDays/365;
            }
        }
    }

    [Flags]
    public enum EmployeeType
    {
        [Description("展厅销售")]
        FieldSaler = 1,

        [Description("电话销售")]
        TelSaler = 2,

        [Description("服务顾问")]
        ServiceConsultant = 4,

        [Description("客户专员")]
        AccountSpecialist = 8,

        [Description("车间主管")]
        WorkshopSupervisor = 16
    }

    public enum SellerGrade
    {
        [Description("初级")]
        LOW = 0,
        [Description("中级")]
        MIDDLE = 1,
        [Description("高级")]
        HIGH=2
    }

    public enum Status
    {
        [Description("在岗")]
        NORMAL = 0,
        [Description("离职")]
        LEAVEOFFICE = 1,
        [Description("升迁")]
        PROMOTE = 2
    }
}
